package com.bailian.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bailian.common.annotation.Log;
import com.bailian.common.core.controller.BaseController;
import com.bailian.common.core.domain.AjaxResult;
import com.bailian.common.enums.BusinessType;
import com.bailian.system.domain.BlParkArea;
import com.bailian.system.service.IBlParkAreaService;
import com.bailian.common.utils.poi.ExcelUtil;
import com.bailian.common.core.page.TableDataInfo;

/**
 * 园区区域Controller
 * 
 * @author ruoyi
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/system/area")
public class BlParkAreaController extends BaseController
{
    @Autowired
    private IBlParkAreaService blParkAreaService;

    /**
     * 查询园区区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlParkArea blParkArea)
    {
        startPage();
        List<BlParkArea> list = blParkAreaService.selectBlParkAreaList(blParkArea);
        return getDataTable(list);
    }

    /**
     * 导出园区区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:export')")
    @Log(title = "园区区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlParkArea blParkArea)
    {
        List<BlParkArea> list = blParkAreaService.selectBlParkAreaList(blParkArea);
        ExcelUtil<BlParkArea> util = new ExcelUtil<BlParkArea>(BlParkArea.class);
        util.exportExcel(response, list, "园区区域数据");
    }

    /**
     * 获取园区区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blParkAreaService.selectBlParkAreaById(id));
    }

    /**
     * 新增园区区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:add')")
    @Log(title = "园区区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlParkArea blParkArea)
    {
        return toAjax(blParkAreaService.insertBlParkArea(blParkArea));
    }

    /**
     * 修改园区区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:edit')")
    @Log(title = "园区区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlParkArea blParkArea)
    {
        return toAjax(blParkAreaService.updateBlParkArea(blParkArea));
    }

    /**
     * 删除园区区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:remove')")
    @Log(title = "园区区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blParkAreaService.deleteBlParkAreaByIds(ids));
    }
}
